package com.android.server.mock.performer.settings;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Arrays;
import java.util.List;

public class MockSettingsItem {
    private String id;
    private String name;
    private String value;

    public MockSettingsItem(String id, String name, String value) {
        this.id = id;
        this.name = name;
        this.value = value;
    }

    public static MockSettingsItem create(JSONObject object) {
        try {
            String id = object.getString("_id");
            String name = object.getString("name");
            String value = object.getString("value");
            return new MockSettingsItem(id, name, value);
        } catch (JSONException e) {
            return null;
        }
    }

    /**
     * 部分 value 可能会用到
     * com.tencent.mm,com.tencent.mobileqq,com.whatsapp,com.tencent.tmgp.sgame,com.netease.onmyoji.mi
     */
    public List<String> parseValue2List() {
        return Arrays.asList(value.split(","));
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
